package string;

/**
 * String支持正则表达式的方法三:
 * String replaceAll(String regex,String replacement)
 * 将当前字符串中满足正则表达式的部分替换为给定内容
 */

public class ReplaceallDemo {
    public static void main(String[] args) {
        String line ="abc123def456ghi";
        line =line.replaceAll("[a-z]+","NUMBER");
        System.out.println(line);

         /*
            和谐用语
         */
        String regex = "(wqnmlgb|dsb|cnm|nc|mdzz|nmsl|djb)";

        String message = "wqnmlgb!你个dsb,你怎么这么的nc.不能玩别玩，你个djb!";
        message = message.replaceAll(regex,"***");
        System.out.println(message);
    }
}
